/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.ac.c0910g.assignment.DAO;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import vn.ac.c0910g.assignment.Entity.Feedback;
import vn.ac.c0910g.assignment.Entity.FeedbackFacade;

/**
 *
 * @author BachLe
 */
public class FeedbackDAO {
    FeedbackFacade feedbackFacade = lookupFeedbackFacadeBean();

    public FeedbackDAO(){

    }
    private FeedbackFacade lookupFeedbackFacadeBean() {
        try {
            Context c = new InitialContext();
            return (FeedbackFacade) c.lookup("java:global/Alluring_Decors/Alluring_Decors-ejb/FeedbackFacade!vn.ac.c0910g.assignment.Entity.FeedbackFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<Feedback> getAllFeedback(){
        return this.feedbackFacade.findAll();
    }

    public void addFeedback(Feedback feedback){
        feedbackFacade.create(feedback);
    }

    public void updateFeedback(Feedback feedback){
        feedbackFacade.edit(feedback);
    }

    public void deleteFeedback(Feedback feedback){
        feedbackFacade.remove(feedback);
    }

    public Feedback findFeedbackById(String Id){
        return feedbackFacade.find(Id);
    }
}
